package com.ticket.dao.impl;

import com.ticket.dao.MovieDao;
import com.ticket.entity.Movie;
import com.ticket.util.Page;

import java.util.List;

/**
 * @author 全谢民
 * @version 8.0
 * @description: TODO 电影表的实现类
 * @date 2023/10/216:24
 */
public class MovieDaoImpl  {
//    CommonDao dao = new CommonDao();

    /*
     * @author 全谢民
     * @description TODO 前端首页获取评分前1/2-7的电影
     * @date 2023/10/2 17:51
     */
    public Page<Movie> selMovie(Page page){
        Page<Movie> moviePage=new Page(page.getPageSize(), page.getCurrPageNo());
        String countSql = "select count(1) from movie ";//where movie_state = 1
        String dataSql = "select * from movie  order by movie_score desc ";//where movie_state = 1
        try {
            //moviePage =dao.exeQueryPage(Movie.class,moviePage,countSql,dataSql,new Movie());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return moviePage;
    }

    public int selMovieCount(Page page) {
        return 0;
    }

    public List<Movie> selMovieList(Page page) {
        return null;
    }

    /*
     * @author 全谢民
     * @description TODO 分类页面电影查询
     * @date 2023/10/3 13:51
     */
    public Page<Movie> movieClassification(Page<Movie> page, Movie movieAddress) {

        String countSql = "select count(1) from movie where 1 = 1  ";
        String dataSql =  "select \n" +
                "movie_address_name as movieAddressName,\n" +
                "movie_id as movieId ,\n" +
                "movie_cn_name as movieCnName,\n" +
                "movie_score as movieScore ,\n" +
                "movie_boxOffice as movieBoxOffice,\n" +
                "movie_commentCount as movieCommentCount,\n" +
                "movie_releaseDate as movieReleaseDate,\n" +
                "movie_picture as moviePicture,\n" +
                "movie_state as movieState,\n" +
                "price_start_range as priceStartRange,\n" +
                "price_finish_range as priceFinishRange,\n" +
                "dimensionType\n" +
                "from movie,movie_address where movie.movie_address_id = movie_address.movie_address_id";
        if(movieAddress.getMovieCnName()!="" && movieAddress.getMovieCnName() != null){
            countSql += " and movie_state = 2 and  movie_cn_name = #{movieCnName} ";
            dataSql += " and movie_state = 2 and  movie_cn_name = #{movieCnName} ";
        }else{
            countSql += " and movie_state = 2 or  movie_state = 3 ";
            dataSql += " and movie_state = 2 or  movie_state = 3 ";
        }
        try {
           // page =dao.exeQueryPage(Movie.class,page,countSql,dataSql,movieAddress);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return page;
    }
}
